
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[spSchedule_CreateSchedule]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spSchedule_CreateSchedule]
GO

GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Eric Liew
-- Create date: 6/2/2009
-- Description:	Get a Plate
-- =============================================
CREATE PROCEDURE [dbo].[spSchedule_CreateSchedule]
(
		@ScheduleDate DATETIME,
		@ShiftId	INT
)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON
	DECLARE @ScheduleId int;


	INSERT Schedule
	(ShiftId, ScheduleDate)
	VALUES
	(@ShiftId, @ScheduleDate)
	
	SET @ScheduleId = @@IDENTITY 
 	
 	INSERT ScheduleDriverTaxi
 	(ScheduleId, TaxiId)
 	SELECT @ScheduleId, TaxiId
 	FROM Taxi
 	
 	SELECT @ScheduleId
 	

END
GO
